package jmotioncapture.geometry2D;

import java.util.Vector;

import jmotioncapture.calculation.GeomCalculation;

/**
 * This class stored a vector of {@link jmotioncapture.geometry2D.Point} that
 * bounded a rectangle.<br>
 * <br>
 * Before creating this, please ensure the following:
 * 
 * <li> Use
 * {@link jmotioncapture.calculation.ShapeRecognizer#isRectangle(Vector)} to
 * confirm the <Code>Vector</code> of point can form a rectangle.</li>
 * 
 * <br>
 * &nbsp;<br>
 * 
 * @author Kenneth
 * @since 1.0.0
 */
public class Rectangle {

	/**
	 * Tolerance of angle. If set to 10, that mean each angle of rectangel can
	 * be 80 < x < 100.<br>
	 * {@link jmotioncapture.calculation.ShapeRecognizer#isRectangle(Vector)}
	 * is using this variable to decide the point is a rectangle or not.
	 */
	public static double ANGLE_TOLERANCE = 5;

	/**
	 * Points bounded the Rectangle.
	 * 
	 * @since 1.0.0
	 */
	private Vector<Point> pts;

	/**
	 * When creating the rectanlge with using this constructor, it already
	 * assumed that the input points MUST bounded a rectangle.
	 * 
	 * @see jmotioncapture.calculation.ShapeRecognizer
	 * @param pts
	 */
	public Rectangle(Vector<Point> pts) {
		this.pts = pts;
	}

	/**
	 * Get the points, represented by the returned <code>Vector</code>. <br>
	 * 
	 * @return Points bounded the rectangle.
	 */
	public Vector<Point> getPoints() {
		return pts;
	}

	/**
	 * Get the size of the rectengle, represented by the returned
	 * <code>double</code>. <br>
	 * Using {@link jmotioncapture.calculation.GeomCalculation#nPointsArea(Vector, boolean)} method to implement.
	 * 
	 * @return size of the rectengle.
	 */
	public double getSize() {
		return GeomCalculation.nPointsArea(pts, true);
	}
}
